﻿using GalaSoft.MvvmLight.Messaging;
using MVVMLightLesson.ViewModels;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MVVMLightLesson.Views
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            //this.DataContext = new MainViewModel();

            Messenger.Default.Register<string>(this, ExecuteMessage);

            Messenger.Default.Register<string>(this,"aibu", ExecuteMessage1);
        }

        private void ExecuteMessage1(string obj)
        {
            Console.WriteLine("aibu" + obj);
        }

        private void ExecuteMessage(string obj)
        {
            // 被VM请求打开一个弹窗，如何获取返回结果  DialogResult
            new SubWin() { Owner = this }.ShowDialog();
        }
    }
}